//
//  U9GamblingManager.m
//  U9WatchGame
//
//  Created by uuu9 on 2017/4/28.
//  Copyright © 2017年 Jason. All rights reserved.
//

#import "U9GamblingManager.h"
#import "U9GamblingListModel.h"
#import "U9MyGamblingDetailListModel.h"
#import "GamblingModel.h"

@implementation U9GamblingManager

+ (void)getGamblingListWithMatchID:(NSString *)matchid andUserID:(NSString *)userid andCompletionHandle:(void(^)(U9GamblingListModel *model, NSError *error))complete{
    NSString *param = [NSString stringWithFormat:@"cid=%@&userid=%@",matchid,userid];
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kGetGamblingList]
    parameters:param
completionHandler:^(id responseObj, NSError *error) {
    U9GamblingListModel *model = [U9GamblingListModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}



+ (void)getGamblingListWithLastTime:(NSString *)lastTime andUserID:(NSString *)userid andCompletionHandle:(void(^)(U9MyGamblingDetailListModel *model, NSError *error))complete{
    NSString *param = [NSString stringWithFormat:@"userid=%@&lastdate=%@",userid,lastTime];
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kGetUserGamblingList]
    parameters:param
completionHandler:^(id responseObj, NSError *error) {
    U9MyGamblingDetailListModel *model = [U9MyGamblingDetailListModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
    
}



+ (void)betWithCid:(NSString *)cid andUserid:(NSString *)userid andBo:(NSInteger)bo andlotype:(NSInteger)lotype andBettarget:(NSInteger)target andScore:(NSInteger)score andCompletionHandle:(void(^)(GamblingModel *model, NSError *error))complete{
    NSString *param = [NSString stringWithFormat:@"cid=%@&userid=%@&bo=%li&lotype=%li&bettarget=%li&score=%li",cid,userid,(long)bo,(long)lotype,target,score];
     
    [self POSTBase64:[NSString stringWithFormat:@"%@%@",Api_URL,kBetToMatch]
          parameters:param
   completionHandler:^(id responseObj, NSError *error) {
       GamblingModel *model;
       if ([responseObj[@"error_code"] intValue] == 0) {
           model = [GamblingModel mj_objectWithKeyValues:responseObj[@"output"]];
       } else{
           error = [self createError:responseObj[@"error_msg"]];
       }
       complete(model,error);
   }];
    
}
@end
